#FindOPENSSL.cmake:FIND_PACKAGE_HANDLE_STANDARD_ARGS(OPENSSL REQUIRED_VARS OPENSSL_LIBRARY OPENSSL_INCLUDE_DIR VERSION_VAR OPENSSL_VERSION HANDLE_COMPONENTS) 
if(NOT TARGET openssl)
    set(LIBNAME      openssl)
    set(LIB_DIR_NAME openssl-master)
    set(ALL_LIB_SRC_DIR ${CMAKE_CURRENT_LIST_DIR}/../thirdparty)
    set(ALL_LIB_BIN_DIR ${CMAKE_BINARY_DIR}/thirdparty)
    set(${LIBNAME}_SRC_DIR ${ALL_LIB_SRC_DIR}/${LIB_DIR_NAME})
    set(${LIBNAME}_BIN_DIR ${ALL_LIB_BIN_DIR}/${LIB_DIR_NAME})
    message("${LIBNAME}_SRC_DIR:${${LIBNAME}_SRC_DIR}")
    message("${LIBNAME}_BIN_DIR:${${LIBNAME}_BIN_DIR}")
    if(CMAKE_SYSTEM_NAME MATCHES "Linux")
        add_compile_definitions(DYZ)
    endif()
    add_subdirectory(${${LIBNAME}_SRC_DIR}/)
endif()

set(OPENSSL_ROOT_DIR     ${${LIBNAME}_SRC_DIR})

set(OPENSSL_INCLUDE_DIRS ${OPENSSL_ROOT_DIR}   ${OPENSSL_ROOT_DIR}/src   ${OPENSSL_ROOT_DIR}/include   ${${LIBNAME}_BIN_DIR}/      ${${LIBNAME}_BIN_DIR}/include  )
set(OPENSSL_LIBRARY_DIRS ${OPENSSL_ROOT_DIR}   ${OPENSSL_ROOT_DIR}/lib   ${${LIBNAME}_BIN_DIR}/Debug   ${${LIBNAME}_BIN_DIR}/      ${${LIBNAME}_BIN_DIR}/lib      )

set(OPENSSL_LIBRARY   $<TARGET_OBJECTS:ssl> )
set(OPENSSL_LIBRARIES $<TARGET_OBJECTS:ssl> $<TARGET_OBJECTS:crypto>)   # libssl  libcrypto

set(SSL_LIBRARY       $<TARGET_OBJECTS:ssl>)
set(SSL_LIBRARIES     $<TARGET_OBJECTS:ssl> $<TARGET_OBJECTS:crypto>)

#set(SSL_LIBRARY       libssl)
#set(SSL_LIBRARIES     libcrypto)

include_directories(${OPENSSL_INCLUDE_DIRS}  )
link_directories   (${OPENSSL_LIBRARY_DIRS}  )